"""
__project__ = 'thc'
__file_name__ = '滑动解锁'
__author__ = 'thc'
__time__ = '2020/12/29/029 15:21'
__product_name = PyCharm
-*- coding:utf-8 -*-
"""

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import UnexpectedAlertPresentException

opt = webdriver.ChromeOptions()
opt.add_experimental_option('w3c', False)
driver = webdriver.Chrome(chrome_options=opt)
driver.get("https://www.helloweba.net/demo/2017/unlock/")
a = driver.find_elements_by_class_name('slide-to-unlock-progress')[0]
action = ActionChains(driver)
action.click_and_hold(a).perform()
for i in range(200):
    try:
        action.move_by_offset(2, 0).perform()
    except UnexpectedAlertPresentException:
        break
alert = driver.switch_to.alert
print(alert.text)
alert.accept()


